<template>
  <div class="container">
    首页
  </div>
</template>

<script>
import card from '@/components/card'
import router from '@/router/routes'
import { filter } from '@/utils/filter'
import { islogin } from '@/auth/islogin'
import { workerApi } from '@/api/worker'
import { wxlogin } from '@/auth/wxLogin'
import store from '@/store'

export default {
  onShow() {
    var that = this
    

    islogin(function() {
      //如果当前为登录状态，则将wxstorage中存入的数据取出，放入vuex里进行状态管理
      var token = wx.getStorageSync('sessionToken');

      store.commit('SET_TOKEN',token)
      store.commit('SET_ISLOGIN',true)

      that.refech()

      wx.reLaunch({
          url: '../../pages/index/index'
      })
    })
  },
  created() {
  },
  methods: {
    refech() {
      store.dispatch('GetWorkerInfo').then(res => {
        store.commit('SET_USER_INFO',res.data)
      })
    }
    // getWorkerInfo() {
    //   store
    //     .dispatch('GetWorkerInfo')
    //     .then(res => {
    //       // 拉取用户信息
    //     })
    //     .catch(() => {
    //       store.dispatch('FedLogOut').then(() => {
    //         wx.showToast({
    //           title: '验证失败,请重新登录',
    //           duration: 2000
    //         })
    //         wx.navigateTo({ url: '../login/index' })
    //       })
    //     })
    // }
  }
}
</script>

<style scoped>
</style>
